
/**
*
* @ author: hxwy
* @ email: 928936715@qq.com
* @ date: 2020-04-14 12:12
*/
export default class UIMgr extends Laya.Script {

    socre_txt : Laya.Text;
    socre:number = 0;
    gameOverPanle : Laya.Sprite;
    constructor() {
        super();
    }

    onAwake()
    {
        this.socre_txt = this.owner.getChildByName("Socre") as Laya.Text;
        Laya.stage.on("AddSocre",this,this.AddSocre);
        this.gameOverPanle = this.owner.getChildByName("gameOverPanle") as Laya.Sprite;
        this.gameOverPanle.visible = false;
        Laya.stage.on("GameOver",this,this.GameOver);
    }

    AddSocre(socre : number)
    {
        this.socre+=socre;
        this.socre_txt.text = this.socre.toString();
    }
    GameOver()
    {
        (this.gameOverPanle.getChildByName("txt_socre") as Laya.Text).text = this.socre.toString();
        let btn_Continue = (this.gameOverPanle.getChildByName("btn_Continue") as Laya.Button);
        btn_Continue.on(Laya.Event.CLICK,this,function(){
            this.gameOverPanle.visible = false;
            this.socre = 0;
            this.socre_txt.visible = true;
            this.socre_txt.text = "0";
            Laya.stage.event("ContinueGame");
        });
        this.gameOverPanle.visible = true;
        this.socre_txt.visible = false;
    }
}
